cmake_minimum_required(VERSION 2.6)
project(Game)

include_directories(
    ${PROJECT_SOURCE_DIR}
)

set(GameSRC
    Common.h
    Common.cc
    GameApplication.h
    GameApplication.cc
    ErrorHandler.cc
    GlobalVars.h
    GlobalVars.cc
    Main.cc
)

set(Game_Game_SRC
    Game/SharedDefines.h
    Game/DBCEnum.h
    Game/DBCFmt.h
    Game/DBCStores.h
    Game/DBCStores.cc
    Game/DBCStructure.h
    Game/SQLStorageFmt.h
    Game/SQLStorages.h
    Game/SQLStorages.cc
    Game/ObjectDefines.h
    Game/Object.h
    Game/Object.cc
    Game/WorldObjectDefines.h
    Game/WorldObject.h
    Game/WorldObject.cc
    Game/UnitDefines.h
    Game/Unit.h
    Game/Unit.cc
    Game/ObjectManagerDefine.h
    Game/ObjectManager.h
    Game/ObjectManager.cc
    Game/ObjectManagerLoad.cc
    Game/ObjectManagerLoadPlayerInfo.cc
    Game/ObjectGuid.h
    Game/ObjectGuid.cc
    Game/Creature.h
    Game/Pet.h
    Game/PlayerDefines.h
    Game/Player.h
    Game/Player.cc
    Game/PlayerCharacter.cc
    Game/ItemPrototype.h
)

set(Game_Server_SRC
    Server/WorldSocketDelegate.h
    Server/WorldSocketDelegate.cc
    Server/WorldSocketDelegateFactory.h
    Server/AuthSession.h
    Server/AuthSession.cc
    Server/AuthSessionManager.h
    Server/AuthSessionManager.cc
    Server/WorldSession.h
    Server/WorldSession.cc
    Server/PacketFilter.h
    Server/PacketFilter.cc
    Server/OpcodeHandler.h
    Server/OpcodeHandler.cc
)

set(Game_World_SRC
    World/WorldDefines.h
    World/World.h
    World/World.cc
    World/CharacterHandler.cc
    World/AddonHandler.h
    World/AddonHandler.cc
)

if (WIN32)
    set(GameSRC Game.rc ${GameSRC})
endif()

if (MSVC)
    source_group("Game" FILES ${Game_Game_SRC})
    source_group("Server" FILES ${Game_Server_SRC})
    source_group("World" FILES ${Game_World_SRC})
endif()

add_executable(Game 
    ${GameSRC}
    ${Game_Game_SRC} 
    ${Game_Server_SRC} 
    ${Game_World_SRC}
)
target_link_libraries(Game
    Shared
    NodeCpp
    tinyxml
    zlib
    ${LIBEVENT_LIBRARY}
    ${OPENSSL_LIBRARY}
    ${MYSQL_LIBRARY}
)

if (WIN32)
target_link_libraries(Game ws2_32 dbghelp)
elseif(UNIX)
target_link_libraries(Game pthread)
endif()

add_custom_command(TARGET Game
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/Game.conf ${PROJECT_BINARY_DIR}/
)